#include<bits/stdc++.h>
using namespace std;
int limit_n[] = {-1, 1000, 1000, 1000, 100000, 100000, 1000000, 1000000, 1000000, 1000000, 1000000};
int limit_weight = 1000;
string name = "kZimeAndGit";
int main()
{
    for (int c = 7; c <= 10; ++c)
    {
        int n = limit_n[c];
        string this_name = name + to_string(c);
        ofstream in_file(this_name + ".in");
        in_file << n << endl;
        random_device grd;
        uniform_int_distribution<int>  rand_weight(1, limit_weight);
        vector<int> is_exist, unused;
        for (int i = 2; i <= n; ++i) unused.push_back(i);
        is_exist.push_back(1);
        for (int i = 1; i < n; ++i)
        {
            uniform_int_distribution<int> rand_father(0, is_exist.size() - 1), rand_child(0, unused.size() - 1);
            int r1 = rand_father(grd), r2 = rand_child(grd);
            int father = is_exist[r1], child = unused[r2], weight = rand_weight(grd);
            is_exist.push_back(child), unused.erase(unused.begin() + r2);
            in_file << father << ' ' << child << ' ' << weight << endl;
        }
    }
}
